Skip to content

fix: pass prompter through to initModule to prevent duplicate stdin listeners#770

Merged
pyramation merged 3 commits intomainfrom
devin/1772489252-fix-init-prompter-passthrough
Mar 3, 2026
Merged

fix: pass prompter through to initModule to prevent duplicate stdin listeners#770
pyramation merged 3 commits intomainfrom
devin/1772489252-fix-init-prompter-passthrough

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Mar 2, 2026

fix: pass prompter through initModule to prevent duplicate stdin listeners

Summary

When using pgpm init -w (workspace + module in one command), initModule() calls scaffoldTemplate() without the existing Inquirerer prompter. If the module template has unanswered variables, promptUser() in genomic creates a second Inquirerer instance on process.stdin while the original is still active. Two readline interfaces and two TerminalKeypress data handlers on the same stdin causes double-echoed keystrokes and input conflicts.

This PR adds an optional prompter field to InitModuleOptions and threads it through initModule()scaffoldTemplate(), so the existing instance is reused instead of creating a duplicate.

Companion PR: dev-utils #67 (merged & published) fixes TerminalKeypress.pause() to reset raw mode after interactive prompts, and Inquirerer.close() to nullify references for safe double-close detection.

Updates since last revision

Bumped all inquirerer-related dependencies to the newly published versions that include the companion fix:

Package Old New
inquirerer ^4.4.0 / ^4.5.0 ^4.5.2
@inquirerer/utils ^3.2.3 / ^3.3.0 ^3.3.1
@inquirerer/test ^1.3.0 ^1.3.3
genomic ^5.3.0 ^5.3.5

Updated in: graphql/codegen, packages/cli, packages/csv-to-pg, pgpm/cli, pgpm/core.

Review & Testing Checklist for Human

  • Run pgpm init -w interactively in a real terminal: This is a TTY-only bug — CI cannot catch regressions. Confirm no double-echoed keystrokes during workspace name, module name, and extensions prompts.
  • Run standalone pgpm init (without -w): The prompter field is optional so existing callers are unaffected, but worth a smoke test.
  • Confirm the inline import('inquirerer').Inquirerer type in InitModuleOptions is acceptable vs a top-level import. Build passes but this is a style choice.

Notes

  • Only the pgpm workspace code path (if (project.workspacePath) in handleModuleInit) goes through initModule(). The other two scaffoldTemplate call sites already pass prompter directly.
  • The companion dev-utils PR addresses the defensive side (raw mode cleanup, close nullification), while this PR addresses the root cause (preventing duplicate instances).
  • The lockfile diff is large due to pnpm reformatting — the actual dependency changes are only the four packages listed above.

Link to Devin Session: https://app.devin.ai/sessions/178a5957a56e4141bd3fd4d0a5e4a508
Requested by: @pyramation


Open with Devin

…isteners

When using pgpm init -w, the module scaffolding via initModule() was calling
scaffoldTemplate() without passing the existing prompter. This caused a new
Inquirerer instance to be created on process.stdin while the original was still
active, resulting in double-echoed keystrokes and input conflicts.

- Add optional prompter field to InitModuleOptions
- Pass prompter through initModule() to scaffoldTemplate()
- Pass prompter from handleModuleInit() to project.initModule()
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

…c to latest versions

- inquirerer: ^4.5.2
- @inquirerer/utils: ^3.3.1
- @inquirerer/test: ^1.3.3
- genomic: ^5.3.5
@pyramation pyramation merged commit ef6b824 into main Mar 3, 2026
44 checks passed
@pyramation pyramation deleted the devin/1772489252-fix-init-prompter-passthrough branch March 3, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant